package com.neusoft.controller;

import com.neusoft.entity.MedicalRecord;
import com.neusoft.service.MedicalRecordService;
import com.neusoft.utils.Result;
import com.sun.org.apache.bcel.internal.generic.PUSH;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author akemihomurasama
 */
@RestController
@RequestMapping("/medicalRecord")
@CrossOrigin
public class MedicalRecordController {
    @Autowired
    private MedicalRecordService medicalRecordService;

    /**
     * 存储患者病历首页信息
     *
     * @param medicalRecord 患者病历首页信息
     * @return Result 插入结果
     */
    @RequestMapping("/saveRecord")
    public Result saveRecord(@RequestBody MedicalRecord medicalRecord) {
        return medicalRecordService.saveRecord(medicalRecord);
    }

    /**
     * 根据患者病历id查询病历首页信息
     *
     * @param caseNumber 病历id
     * @return 病历首页信息
     */
    @RequestMapping("/queryRecordByCaseNum/{caseNumber}")
    public Result queryRecordByCaseNum(@PathVariable String caseNumber) {
        return medicalRecordService.queryRecordByCaseNum(caseNumber);
    }

    /**
     * 更新病历首页信息
     *
     * @param medicalRecord 信息
     * @return 更新结果
     */
    @RequestMapping("/updateRecord")
    public Result updateRecord(@RequestBody MedicalRecord medicalRecord) {
        return medicalRecordService.updateRecord(medicalRecord);
    }

    /**
     * 根据患病历首页id查询病历中的疾病列表
     *
     * @param recordId 病历首页id
     * @return 疾病列表
     */
    @RequestMapping("/queryDiseaseListByRecordId/{recordId}")
    public Result queryDiseaseListByRecordId(@PathVariable("recordId") int recordId) {
        return medicalRecordService.queryDiseaseListByRecordId(recordId);
    }
}
